/**
 * 
 */
package com.eya.controller;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eya.domain.User;

/**
 * 测试@RequestBody是否能将JSON参数转换成对象或者对象的集合
 * @author luolin
 *
 * @version $id:RequestBodyTestController.java,v 0.1 2015年8月25日 下午4:00:49 luolin Exp $
 */
@Controller
@RequestMapping("requestbody")
public class RequestBodyTestController {

    @RequestMapping("totest")
    public String toPage() {
        return "requestbody/test";
    }

    @ResponseBody
    @RequestMapping("getjsondata.json")
    public User getJSONData() {
        System.out.println("获取数据....");
        return new User(1, "luolin", "male");
    }

    @RequestMapping("dotest")
    public void doTest(@RequestBody User user) {
        System.out.println(JSONObject.fromObject(user));
    }
}
